package view;

import java.util.ArrayList;

import model.GamePiece;
import model.Player;
import model.Slot;
import controller.Controller;

import java.io.*;

/**
 * This class displays the 13 X 7 triangular grid.
 * It also print various messages required to inform user time to time during the game.
 *
 */
public class GameViewer
{

    public static void display(ArrayList<ArrayList<GamePiece>> grid)
    {
        for (int i = grid.size() - 1; i >= 0; i--)
        {
            System.out.print(i + 1);
            
            for (int m = 0; m < 2 * i + 1; m++)
            {
                System.out.print(" ");
            }

            for (int j = 0; j < grid.get(i).size(); j++)
            {
                GamePiece piece = grid.get(i).get(j);
                switch (piece)
                {
                    case NO_PIECE:
                        System.out.print("* ");
                        break;
                    case BLACK:
                        System.out.print("b ");
                        break;
                    case WHITE:
                        System.out.print("W ");
                        break;
                }
            }
            System.out.print("\n");
        }
        System.out.println("  A B C D E F G H I J K L M\n");
    }

    public static void printWelcomeMessage()
    {
        System.out.println("Welcome to the polarized ladder game.");
    }

    public static void printNewGameMessage()
    {
        System.out.println("Game on !");
    }    
    
    public static void printTieMessage()
    {
        System.out.println("It's a tie, guys.");    
    }
    
    public static void printStopMessage()
    {
        System.out.println("Game Ended!");    
    }

    public static void printPlayerWinsMessage(Player player)
    {
        System.out.println("Player " + player.getName() + " WINS.");
    }

    public static void printPlayerTurnEndsMessage(Player player, String move)
    {
        System.out.println("Player " + player.getName() + " just played " + move + ".");
    }
    
    public static String printPlayerSelect(){
    	
    	System.out.println("\n*********Select Player Configuration*********\n");
    	System.out.println("1. Computer Player vs. Computer Player");
    	System.out.println("2. Human Player vs. Computer Player");
    	System.out.println("3. Computer Player vs. Human Player");
    	System.out.println("4. Human Player vs. Human Player");
    	System.out.println("5. Exit");
    	System.out.println("\nEnter your Choice :: ");
    	
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String ch=null;
    	try{
    		ch = br.readLine();
    	}
    	catch(IOException e){
    		System.out.println("IO error!");
            System.exit(1);
    	}
    	catch (Exception e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    	return ch.trim();
    }
}
